var DotoBrowser = {
	
	initBrowser: function() {
		var jsm = {};
		Components.utils.import("resource://doto/modules/services.js", jsm);
		jsm.DotoManager.init();
		
		setTimeout('DotoBrowser.checkVersion()', 500);
	},
	
	checkVersion: function() {
		var version = Application.prefs.getValue('extensions.doto.version', '');
		var extver = Application.extensions.get('doto@mijia.org').version;
		var openDoto = false;
		
		if (version) {
			try {
				var x = Components.classes['@mozilla.org/xpcom/version-comparator;1']
					.getService(Components.interfaces.nsIVersionComparator)
					.compare(version, extver);
				if (x < 0) {
					openDoto = true;
				} 
			} catch (e) {
				openDoto = true;
			}
		} else {
			openDoto = true;
		}
		Application.prefs.setValue('extensions.doto.version', extver);
		if (openDoto) {
			DotoBrowser.openAboutDoto();
		}
	},
	
	openAboutDoto: function() {
		gBrowser.selectedTab = gBrowser.addTab("about:todo");
	},
}